403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/03120301.html
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Format Function</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">


<a name="format"></a>
<a name="bm_id3153539"></a>
  <meta itemprop="keywords" content="Format function">



<h1 id="hd_id3153539" dir="auto">Format Function</h1>
<p id="par_id3156042" class="paragraph" dir="auto">Converts a numeric expression to a string, and then formats it according to the format that you specify.</p>


<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Format(expression [, format As String]) As String
</code></pre></div>

<a name="ValueParms"></a>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id3149415" class="paragraph" dir="auto"> <span class="emph">expression</span>: Numeric expression that you want to convert to a formatted string.</p>
<p id="par_id3147531" class="paragraph" dir="auto"> <span class="emph">format</span>: String that specifies the format code for the number. If <span class="literal">format</span> is omitted, the Format function works like the LibreOffice Basic <span class="literal">Str()</span> function.</p>

<div class="embedded">
<a name="functvalue"></a>
<h3 id="hd_id061420171139087480" dir="auto">Return value:</h3>
</div>
<p id="par_id3148474" class="paragraph" dir="auto">Text string.</p>


<h2 id="hd_id3147561" dir="auto">Formatting Codes</h2>
<a name="codes"></a>
<p id="par_id3147265" class="paragraph" dir="auto">The following list describes the codes that you can use for formatting a numeric expression:</p>
<p id="par_id3153380" class="paragraph" dir="auto"> <span class="emph">0:</span> If <span class="literal">expression</span> has a digit at the position of the 0 in the <span class="literal">format</span> code, the digit is displayed, otherwise a zero is displayed.</p>
<p id="par_id3151210" class="paragraph" dir="auto">If <span class="literal">expression</span> has fewer digits than the number of zeros in the <span class="literal">format</span> code, (on either side of the decimal), leading or trailing zeros are displayed. If the <span class="literal">expression</span> has more digits to the left of the decimal separator than the amount of zeros in the <span class="literal">format</span> code, the additional digits are displayed without formatting.</p>
<p id="par_id3151176" class="paragraph" dir="auto">Decimal places in the <span class="literal">expression</span> are rounded according to the number of zeros that appear after the decimal separator in the <span class="literal">format</span> code.</p>
<p id="par_id3154123" class="paragraph" dir="auto"> <span class="emph">#:</span> If <span class="literal">expression</span> contains a digit at the position of the # placeholder in the <span class="literal">format</span> code, the digit is displayed, otherwise nothing is displayed at this position.</p>
<p id="par_id3148452" class="paragraph" dir="auto">This symbol works like the 0, except that leading or trailing zeroes are not displayed if there are more # characters in the <span class="literal">format</span> code than digits in the <span class="literal">expression</span>. Only the relevant digits of the <span class="literal">expression</span> are displayed.</p>
<p id="par_id3159150" class="paragraph" dir="auto"> <span class="emph">.:</span> The decimal placeholder determines the number of decimal places to the left and right of the decimal separator.</p>
<p id="par_id3159252" class="paragraph" dir="auto">If the <span class="literal">format</span> code contains only # placeholders to the left of this symbol, numbers less than 1 begin with a decimal separator. To always display a leading zero with fractional numbers, use 0 as a placeholder for the first digit to the left of the decimal separator.</p>
<p id="par_id3153368" class="paragraph" dir="auto"> <span class="emph">%:</span> Multiplies the <span class="literal">expression</span>by 100 and inserts the percent sign (%) where the <span class="literal">expression</span> appears in the <span class="literal">format</span> code.</p>
<p id="par_id3149481" class="paragraph" dir="auto"> <span class="emph">E- E+ e- e+ :</span> If the <span class="literal">format</span> code contains at least one digit placeholder (0 or #) to the right of the symbol E-, E+, e-, or e+, the <span class="literal">expression</span> is formatted in the scientific or exponential format. The letter E or e is inserted between the number and the exponent. The number of placeholders for digits to the right of the symbol determines the number of digits in the exponent.</p>
<p id="par_id3149262" class="paragraph" dir="auto">If the exponent is negative, a minus sign is displayed directly before an exponent with E-, E+, e-, e+. If the exponent is positive, a plus sign is only displayed before exponents with E+ or e+.</p>
<p id="par_id3148617" class="paragraph" dir="auto">The thousands delimiter is displayed if the <span class="literal">format</span> code contains the delimiter enclosed by digit placeholders (0 or #).</p>
<p id="par_id3163713" class="paragraph" dir="auto">The use of a period as a thousands and decimal separator is dependent on the regional setting. When you enter a number directly in Basic source code, always use a period as decimal delimiter. The actual character displayed as a decimal separator depends on the number format in your system settings.</p>
<p id="par_id3152887" class="paragraph" dir="auto"> <span class="emph">- + $ ( ) space:</span> A plus (+), minus (-), dollar ($), space, or brackets entered directly in the <span class="literal">format</span> code is displayed as a literal character.</p>
<p id="par_id3148576" class="paragraph" dir="auto">To display characters other than the ones listed here, you must precede it by a backslash (\), or enclose it in quotation marks (" ").</p>
<p id="par_id3153139" class="paragraph" dir="auto"> <span class="emph">\ :</span> The backslash displays the next character in the <span class="literal">format</span> code.</p>
<p id="par_id3153366" class="paragraph" dir="auto">Characters in the <span class="literal">format</span> code that have a special meaning can only be displayed as literal characters if they are preceded by a backslash. The backslash itself is not displayed, unless you enter a double backslash (\\) in the format code.</p>
<p id="par_id3155411" class="paragraph" dir="auto">Characters that must be preceded by a backslash in the format code in order to be displayed as literal characters are date- and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, :), numeric-formatting characters (#, 0, %, E, e, comma, period), and string-formatting characters (@, &amp;, &lt;, &gt;, !).</p>
<p id="par_id3145749" class="paragraph" dir="auto">You can also use the following predefined number formats. Except for <span class="literal">"General Number"</span>, all of the predefined format codes return the number as a decimal number with two decimal places.</p>
<p id="par_id3150113" class="paragraph" dir="auto">If you use predefined formats, the name of the format must be enclosed in quotation marks.</p>


<h2 id="hd_id3149377" dir="auto">Predefined format</h2>
<a name="formats"></a>
<p id="par_id3154730" class="paragraph" dir="auto"> <span class="emph">General Number:</span> Numbers are displayed as entered.</p>
<p id="par_id3153158" class="paragraph" dir="auto"> <span class="emph">Currency:</span> Inserts a dollar sign in front of the number and encloses negative numbers in brackets.</p>
<p id="par_id3154490" class="paragraph" dir="auto"> <span class="emph">Fixed:</span> Displays at least one digit in front of the decimal separator.</p>
<p id="par_id3153415" class="paragraph" dir="auto"> <span class="emph">Standard:</span> Displays numbers with a thousands separator.</p>
<p id="par_id3150715" class="paragraph" dir="auto"> <span class="emph">Percent:</span> Multiplies the number by 100 and appends a percent sign to the number.</p>
<p id="par_id3153836" class="paragraph" dir="auto"> <span class="emph">Scientific:</span> Displays numbers in scientific format (for example, 1.00E+03 for 1000).</p>
<p id="par_id3153707" class="paragraph" dir="auto">A <span class="literal">format</span> code can be divided into three sections that are separated by semicolons. The first part defines the format for positive values, the second part for negative values, and the third part for zero. If you only specify one <span class="literal">format</span> code, it applies to all numbers.</p>

  
<div class="embedded">
<a name="languageformat"></a>
<p id="par_id3153381" class="paragraph" dir="auto">You can set the locale used for controlling the formatting numbers, dates and currencies in LibreOffice Basic in <span id="swlnsystextsbasicshared00000003xml_1" class="switchinline"><span hidden="true" id="MACtextsbasicshared00000003xml_1" class="MAC"><span class="emph">LibreOffice - Preferences</span>
</span><span hidden="true" id="defaulttextsbasicshared00000003xml_1"><span class="emph">Tools - Options</span></span></span><span class="emph"> - Languages and Locales - General</span>. In Basic format codes, the decimal point (<span class="emph">.</span>) is always used as <span class="emph">placeholder</span> for the decimal separator defined in your locale and will be replaced by the corresponding character.</p>
<p id="par_id3150870" class="paragraph" dir="auto">The same applies to the locale settings for date, time and currency formats. The Basic format code will be interpreted and displayed according to your locale setting.</p>
</div>
<div class="embedded">
<a name="errorcode"></a>
<h3 id="hd_id3152869" dir="auto">Error codes:</h3>
</div>
<div class="embedded"><p class="embedded" dir="auto">5 Invalid procedure call</p></div>

<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub ExampleFormat
    MsgBox Format(6328.2, "##,##0.00")
    ' always use a period as decimal delimiter when you enter numbers in Basic source code.
    ' displays for example 6,328.20 in English locale, 6.328,20 in German locale.
End Sub
</code></pre></div>
<a name="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a name="related"></a><span class="emph">Related Topics</span>
</p>
<div class="relatedbody" itemprop="mentions">
    <p id="par_id381513082126889" class="paragraph" dir="auto"><a target="_top" href="en-US/text/shared/01/05020301.html">Number format codes</a></p>
    <p id="par_id161599082457466" class="paragraph" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03120300.html">String functions</a></p>
</div>
</div>

</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03120301.xhp" target="_blank">/text/sbasic/shared/03120301.xhp</a></p>
<p dir="auto">Title is: Format Function</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit